package com.yiyi.credit.manage.abutment.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yiyi.credit.manage.abutment.common.enums.InterfacePathEnum;
import com.yiyi.credit.manage.abutment.common.enums.SpendEnum;
import com.yiyi.credit.manage.abutment.common.utils.CcxiSignUtils;
import com.yiyi.credit.manage.abutment.common.utils.DateUtil;
import com.yiyi.credit.manage.abutment.common.utils.UUIDUtil;
import com.yiyi.credit.manage.abutment.common.utils.WebUtil;
import com.yiyi.credit.manage.abutment.mapper.CcxiMapper;
import com.yiyi.credit.manage.abutment.mapper.ProjectAmountWaterMapper;
import com.yiyi.credit.manage.abutment.mapper.ProjectToThirdMapper;
import com.yiyi.credit.manage.model.entity.InterfaceFlow;
import com.yiyi.credit.manage.model.entity.ProjectAmountWater;
import com.yiyi.credit.manage.model.entity.ProjectToThird;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;

@Service
public class CcxiService {

    public static final Logger LOGGER = LoggerFactory.getLogger(CcxiService.class);

    @Value("${ccxi.url}")
    private String url;

    @Value("${ccxi.account}")
    private String account;

    @Value("${ccxi.privateKey}")
    private String ccxiPrivateKey;

    @Autowired
    private CcxiMapper ccxiMapper;

    @Autowired
    private ProjectAmountWaterMapper projectAmountWaterMapper;

    @Autowired
    private ProjectToThirdMapper projectToThirdMapper;

    public List<InterfaceFlow> uniqueRequestNo(String projectCode,String requestNo){
        List<InterfaceFlow> list=ccxiMapper.selectInterfaceFlowByRequestNo(projectCode,requestNo);
        return list;
    }

    public InterfaceFlow queryInterfaceFlowByReqData(Map<String,Object> map){
        String interfaceType = (String) map.get("interfaceType");
        String cid = (String) map.get("cid");
        String name = (String) map.get("name");
        String mobile = (String) map.get("mobile");
        String card = (String) map.get("card");
        String type = (String) map.get("type");
        String key = (String) map.get("key");
        String cat = (String) map.get("cat");
        String month = (String) map.get("month");

        InterfaceFlow interfaceFlow = null;
        List<InterfaceFlow> list = ccxiMapper.selectInterfaceFlowByReqData(interfaceType,cid,name,mobile,card,type,key,cat,month);
        if(list.size()>0) interfaceFlow = list.get(0);
        return interfaceFlow;
    }

    @Async
    public void updateProjectToThirdCost(String accountNumber,String account,String amount,String interfaceType) throws InterruptedException {
        long start = System.currentTimeMillis();
        ProjectToThird pt=projectToThirdMapper.selectProjectToThird(accountNumber,account);
        BigDecimal b_amount=new BigDecimal(amount);
        BigDecimal preCost = pt.getCost();
        BigDecimal aftCost = preCost.add(b_amount);

        ProjectAmountWater pw  = new ProjectAmountWater();
        pw.setId(UUIDUtil.generateOrdId());
        pw.setPrCode(pt.getPrCode());
        pw.settCode(pt.gettCode());
        pw.setInterfaceType(interfaceType);
        pw.setCost(b_amount);
        pw.setPreCost(preCost);
        pw.setAftCost(aftCost);
        pw.setCreateTime(new Date());
        int pwstate =projectAmountWaterMapper.insert(pw);

        String id = pt.getId();
        int state=projectToThirdMapper.updateProjectToThird(b_amount,id);
        LOGGER.info("耗时:{}ms 记录接口花费流水和总金额 ",System.currentTimeMillis()-start);
    }

    public Map<String, Object> interfaceFlowReMap(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

       /* String interfaceType = (String) map.get("interfaceType");
        String cid = (String) map.get("cid");
        String name = (String) map.get("name");
        String mobile = (String) map.get("mobile");
        String card = (String) map.get("card");
        String requestNo = (String) map.get("requestNo");

        InterfaceFlow interfaceFlow = null;
        List<InterfaceFlow> list = ccxiMapper.selectInterfaceFlowByReqData(interfaceType,cid,name,mobile,card);
        if(list.size()>0) interfaceFlow=list.get(0);*/
        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);

        return returnMap;
    }

    public Map<String, Object> interfaceFlowReMul(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);

        return returnMap;
    }

    public Map<String, Object> interfaceFlowReMapRis(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);

        return returnMap;
    }

    public Map<String, Object> interfaceFlowReMapScore(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        String score = null;
        JSONObject factors = null;
        JSONObject grades = null;
        if(respObjcect.get("score")!=null) score = respObjcect.get("score").toString();
        if(respObjcect.get("factors")!=null) factors = (JSONObject)respObjcect.get("factors");
        if(respObjcect.get("grades")!=null) grades = (JSONObject)respObjcect.get("grades");

        JSONObject data = new JSONObject();
        data.put("score",score);
        data.put("factors",factors);
        data.put("grades",grades);

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);

        return returnMap;
    }


    public Map<String, Object> interfaceFlowReMapRisT1(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        String totalNum = respObjcect.get("totalNum").toString();
        String tid = respObjcect.get("tid").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);
        returnMap.put("totalNum",totalNum);
        returnMap.put("tid",tid);

        return returnMap;
    }

    public Map<String, Object> interfaceFlowicinfo(InterfaceFlow interfaceFlow,String requestNo) throws Exception{

        String respStr = interfaceFlow.getRespData();
        String createTime = DateUtil.format(interfaceFlow.getCreateTime());
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("entities")!=null) data = (JSONArray)respObjcect.get("entities");

        Map<String,Object> returnMap = new HashMap<String,Object>();
        returnMap.put("respStr",respStr);
        returnMap.put("code",code);
        returnMap.put("msg",msg);
        returnMap.put("data",data);
        returnMap.put("requestNo",requestNo);
        returnMap.put("createTime",createTime);

        return returnMap;
    }


    public Map<String, Object> identityAuth(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.IDENTITY_AUTH.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.IDENTITY_AUTH.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.IDENTITY_AUTH.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        //String respStr="{\"resCode\":\"2010\",\"resMsg\":\"身份验证成功\",\"tid\" : \"1234567890\",\"sign\":\"75609816D291290C35C009DF5D380A6A\"}";
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        String data = null;
        if(respObjcect.get("data")!=null) data = respObjcect.get("data").toString();

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        /*int updateCost=updateProjectToThirdCost(appId,account,SpendEnum.IDENTITY_AUTH_SPEND.getValue(),InterfacePathEnum.IDENTITY_AUTH.getPath());*/

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> bankCardbin(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.BANK_CARDBIN.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.BANK_CARDBIN.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.BANK_CARDBIN.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        //String respStr="{\"resCode\":\"2010\",\"resMsg\":\"身份验证成功\",\"tid\" : \"1234567890\",\"sign\":\"75609816D291290C35C009DF5D380A6A\"}";
        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> eduQuery(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.EDU_QUERY.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.EDU_QUERY.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.EDU_QUERY.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> criminalQueryScore(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.CRIMINAL_QUERYSCORE.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.CRIMINAL_QUERYSCORE.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.CRIMINAL_QUERYSCORE.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> crditConsumability(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.CREDIT_CONSUMABLIITY.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.CREDIT_CONSUMABLIITY.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.CREDIT_CONSUMABLIITY.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> creditMultiappl(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.CREDIT_MULTIAPPL.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.CREDIT_MULTIAPPL.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.CREDIT_MULTIAPPL.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> creditScoreGeneralFactors(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        /*reqJson.put("reqTid",UUIDUtil.generateOrdId());*/
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.CREDIT_SCORE_GENERAL_FACTORS.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.CREDIT_SCORE_GENERAL_FACTORS.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.CREDIT_SCORE_GENERAL_FACTORS.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();

        String score = null;
        JSONObject factors = null;
        JSONObject grades = null;

        if(respObjcect.get("score")!=null) score = respObjcect.get("score").toString();
        if(respObjcect.get("factors")!=null) factors = (JSONObject)respObjcect.get("factors");
        if(respObjcect.get("grades")!=null) grades = (JSONObject)respObjcect.get("grades");

        JSONObject data = new JSONObject();
        data.put("score",score);
        data.put("factors",factors);
        data.put("grades",grades);

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> idenLocat(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.IDEN_LOCAT.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.IDEN_LOCAT.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.IDEN_LOCAT.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> identity3moT1(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqId",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.TELECOM_IDENTITY.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.TELECOM_IDENTITY.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.TELECOM_IDENTITY.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> autoCncmT2(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.AUTH_CNCM.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.AUTH_CNCM.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.AUTH_CNCM.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> riskinfoCredit(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String name = reqJson.get("name").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("name");
        reqJson.remove("mark");
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        reqJson.put("name",name);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.RISKINFO_CREDIT.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.RISKINFO_CREDIT.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.RISKINFO_CREDIT.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> riskinfoT1(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String name = reqJson.get("name").toString();
        String cid = reqJson.get("cid").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("name");
        reqJson.remove("cid");
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        reqJson.put("name",name);
        reqJson.put("cid",cid);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.RISKINFOT1.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.RISKINFOT1.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.RISKINFOT1.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        String totalNum = respObjcect.get("totalNum").toString();
        String tid = respObjcect.get("tid").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("totalNum",totalNum);
        map.put("tid",tid);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> riskinfoT1Detail(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String tid = reqJson.get("tid").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("tid");
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("tid",tid);
        reqJson.put("fileID",UUIDUtil.generateOrdId());

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.RISKINFOT1DETAIL.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.RISKINFOT1DETAIL.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.RISKINFOT1DETAIL.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> transReportT2(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String card = reqJson.get("card").toString();
        String name = reqJson.get("name").toString();
        String cid = reqJson.get("cid").toString();
        String mobile = reqJson.get("mobile").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");

        reqJson.put("cid",cid);
        reqJson.put("name",name);
        reqJson.put("mobile",mobile);
        reqJson.put("card",card);
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);


        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.TRANSREPORTT2.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.TRANSREPORTT2.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.TRANSREPORTT2.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> cert(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String name = reqJson.get("name").toString();
        String cid = reqJson.get("cid").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");

        reqJson.put("cid",cid);
        reqJson.put("name",name);
        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);


        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.CERT.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.CERT.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.CERT.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }

    public Map<String, Object> vehicleInfo(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String name = reqJson.get("name").toString();
        String cid = reqJson.get("cid").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("name");
        reqJson.put("cid",cid);
        reqJson.put("reqTid",UUIDUtil.generateOrdId());

        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("name",name);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.VEHICLEINFO.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.VEHICLEINFO.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.VEHICLEINFO.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("data")!=null) data = (JSONArray)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> telecomConsumability(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");

        reqJson.put("reqTid",UUIDUtil.generateOrdId());

        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.TELECOMCONSUMABILITY.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.TELECOMCONSUMABILITY.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.TELECOMCONSUMABILITY.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> telecomStatetime(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");

        reqJson.put("reqTid",UUIDUtil.generateOrdId());

        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.TELECOMSTATETIME.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.TELECOMSTATETIME.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.TELECOMSTATETIME.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> icinfoCategory(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("cat");

        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.ICINFO_CATEGORY.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.ICINFO_CATEGORY.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.ICINFO_CATEGORY.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        String tid = null;
        if(respObjcect.get("resMsg") != null)
             tid = respObjcect.get("tid").toString();

        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("tid",tid);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> icinfocategoryPerson(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("cat");

        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.ICINFO_CATEGORY_PERSON_TID.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.ICINFO_CATEGORY_PERSON_TID.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.ICINFO_CATEGORY_PERSON_TID.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> icinfoReport(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String cid = reqJson.get("cid").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("cid");

        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("cid",cid);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.ICINFO_REPORT.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.ICINFO_REPORT.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.ICINFO_REPORT.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONArray data = null;
        if(respObjcect.get("entities")!=null) data = (JSONArray)respObjcect.get("entities");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }


    public Map<String, Object> airtravelTrareport(String reqDate, String appid,String requestNo) throws Exception{
        Map<String,Object> map = new HashMap<String,Object>();
        JSONObject reqJson = JSONObject.parseObject(reqDate);
        String appId = reqJson.get("appId").toString();
        String cidType = reqJson.get("cidType").toString();
        String month = reqJson.get("month").toString();
        reqJson.remove("appId");
        reqJson.remove("sign");
        reqJson.remove("requestNo");
        reqJson.remove("mark");
        reqJson.remove("cidType");
        reqJson.remove("month");

        reqJson.put("reqTid",UUIDUtil.generateOrdId());
        String sign = CcxiSignUtils.sign(reqJson.toJSONString(),ccxiPrivateKey,account);
        reqJson.put("cidType",cidType);
        reqJson.put("month",month);

        String id = UUIDUtil.generateOrdId();
        Date date = new Date();
        String createTime = DateUtil.format(date);
        InterfaceFlow interfaceFlow = new InterfaceFlow();
        interfaceFlow.setId(id);
        interfaceFlow.setCreateTime(date);
        interfaceFlow.setProjectCode(appid);
        interfaceFlow.setPlatformCode(account);
        interfaceFlow.setInterfaceType(InterfacePathEnum.AIRTRAVEL_TRAREPORT.getPath());
        interfaceFlow.setAccount(account);
        interfaceFlow.setRequestNo(requestNo);
        interfaceFlow.setProjectReqDate(reqDate);

        reqJson.put("account",account);
        reqJson.put("sign",sign);
        interfaceFlow.setReqData(reqJson.toString());
        int insertCcxi = ccxiMapper.insert(interfaceFlow);

        TreeMap<String, String> params = JSONObject.parseObject(reqJson.toJSONString(), new TypeReference<TreeMap<String, String>>(){});
        String ccxiUrl = WebUtil.buildUrl(url+ InterfacePathEnum.AIRTRAVEL_TRAREPORT.getPath(),params);
        LOGGER.info("中诚信{}",InterfacePathEnum.AIRTRAVEL_TRAREPORT.getMsg());
        String respStr= WebUtil.doHttpsGet(ccxiUrl);

        JSONObject respObjcect = JSONObject.parseObject(respStr);
        String code = respObjcect.get("resCode").toString();
        String msg = respObjcect.get("resMsg").toString();
        JSONObject data = null;
        if(respObjcect.get("data")!=null) data = (JSONObject)respObjcect.get("data");

        InterfaceFlow interfaceFlowUpdate = new InterfaceFlow();
        interfaceFlowUpdate.setId(id);
        interfaceFlowUpdate.setRespData(respStr);
        interfaceFlowUpdate.setUpdateTime(new Date());
        interfaceFlowUpdate.setResCode(code);
        interfaceFlowUpdate.setResMsg(msg);
        int updateCcxi =ccxiMapper.updateByPrimaryKeySelective(interfaceFlowUpdate);

        map.put("respStr",respStr);
        map.put("code",code);
        map.put("msg",msg);
        map.put("data",data);
        map.put("requestNo",requestNo);
        map.put("createTime",createTime);
        return map;
    }
}

